﻿namespace ExamV5.OnlineExam
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmPrintInfo : Page
    {
        protected Button butPrint;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private int int_0 = 0;
        protected Label labShowUserInfo;
        private PublicFun publicFun_0 = new PublicFun();
        private string string_0 = "";
        protected TextBox txtExamAddressA;
        protected TextBox txtExamDateA;

        protected void butPrint_Click(object sender, EventArgs e)
        {
            this.method_0();
            base.Response.Write("<script>setTimeout(function(){ if (confirm('确定要打印准考证吗？')) { window.print();} },2000)</script>");
        }

        private void method_0()
        {
            int count = 0;
            int num2 = 0;
            if (this.string_0.Length > 1)
            {
                this.string_0 = this.string_0.Substring(0, this.string_0.Length - 1);
            }
            string str3 = this.txtExamAddressA.Text.Trim();
            string str4 = this.txtExamDateA.Text.Trim();
            if (str3.Trim() == "")
            {
                str3 = " ";
            }
            if (str4.Trim() == "")
            {
                str4 = " ";
            }
            this.string_0 = "'" + this.string_0.Replace("|", "','") + "'";
            string values = this.publicFun_0.GetValues("select ExamName from PaperInfo where ID=" + this.int_0, "ExamName");
            this.labShowUserInfo.Text = "";
            string str2 = "";
            string selectCommandText = "select a.UserPhoto,a.UserCode,a.UserName,a.UserSex,a.Worker,a.UserGWName,a.UserSFZH,b.DeptName,a.UserEdu  from UserInfo a,DeptInfo b  where a.DeptID=b.ID and a.UserCode in(" + this.string_0 + ")";
            SqlConnection selectConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            selectConnection.Open();
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommandText, selectConnection);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet, "UserInfo");
            count = dataSet.Tables["UserInfo"].Rows.Count;
            for (int i = 0; i < count; i++)
            {
                num2++;
                if (!(dataSet.Tables["UserInfo"].Rows[i]["UserPhoto"].ToString() == ""))
                {
                    str2 = "<img align='center'  src='../publicFile/" + dataSet.Tables["UserInfo"].Rows[i]["UserPhoto"].ToString() + "' border=0  Width='104px' Height='122px'>";
                }
                else
                {
                    str2 = "<img align='center'  src='../publicFile/SysUserImg.gif' border=0  Width='104px' Height='122px'>";
                }
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<table borderColor='#cccccc'  borderColorDark='#cccccc'  cellSpacing='0' cellPadding='0' border='1'  align='center'  width='650' style='tableStyle'>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<tr height='40'>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td colspan='4'><div align='center' class='STYLE1'><strong>" + values + "准考证</strong></div>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td rowspan='6' width='110'  align='center' ><BR>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t<BR>" + str2;
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t<BR>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t<BR>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t(盖章)<BR>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t<BR>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t</tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t<tr height='35'>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td align='center' width='100'><B>准考证号</B>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td  width='170'  align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["UserCode"].ToString() + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td width='100' align='center'><strong>考生姓名</strong></td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td  width='170' align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["UserName"].ToString() + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t</tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t<tr height='35'>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td align='center' width='100'><B>考生性别</B>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["UserSex"].ToString() + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td width='100' align='center'><strong>考生学历</strong></td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["UserEdu"].ToString() + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t</tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t<tr height='35'>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td align='center' width='100'><B>所属职务</B>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["Worker"].ToString() + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td width='100' align='center'><strong>所属岗位</strong></td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["UserGWName"].ToString() + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t</tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t<tr height='35'>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td align='center' width='100'><B>身份证号</B>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["UserSFZH"].ToString() + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td width='100' align='center'><strong>单位/部门</strong></td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td align='left'>" + dataSet.Tables["UserInfo"].Rows[i]["DeptName"].ToString() + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t</tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t<tr height='35'>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td  align='center' width='100'><B>考试地点</B>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td align='left'>" + str3 + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td width='100' align='center'><strong>考试时间</strong></td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td  align='left'>" + str4 + "&nbsp;</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t</tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t<tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t<td colspan='5' align='left' ><Div style='FONT-SIZE: 9pt; FONT-FAMILY: 宋体'>考生须知<br>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t\t1、考生凭准考证和身份证（军官或士兵证）参加考试，缺一不可。身份证遗失的考生，必须持有临时身份证，或户口所在地派出所开具的带有考生本人照片并加盖公章的身份证明方可参加考试，否则一律不得进入考场参加考试。<br>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t\t2、考生在考前十五分钟内进入考场，按准考证对号入座；考生开考三十分钟后方可离开考场；迟到三十分钟以上者不得进入考场。 <br>3、考生自备橡皮、黑色字迹的签字笔。";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t\t<br>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t\t4、考生不得将与考试有关的书籍、资料带入考场；严禁将手机等通讯工具带至座位（手机不得作为钟表使用，请取消报时功能并关机，放在指定位置）。考试期间凡发现将上述资料、设备带至座位的，该场考试成绩无效；翻阅、使用上述资料、设备的，一律按严重违纪取消考试资格。<br>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t\t5、开考信号发出后方可开始答题；考试终了信号发出后应立即停止答题，严禁将试卷、草稿纸等带出考场。监考老师如数收回考生的试卷、草稿纸后，考生方可离开考场。";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t\t<br>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t\t6、凡在考场内发现作弊行为，本次考试作零分处理。<br>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t\t<B>提示：考生应在考试前一天熟悉考点地址和交通路线，考试当天应特别注意雨雾等恶劣天气及重大活动对交通的影响。</B>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t\t</Div>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t\t</td>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t\t</tr>";
                this.labShowUserInfo.Text = this.labShowUserInfo.Text + "\t</table>";
                num2 = i % 2;
                if (num2 != 0)
                {
                    this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<table borderColor='#cccccc' cellSpacing='0' borderColorDark='#cccccc' cellPadding='0' border='0' align='center' width='650'><tr  height='60'><td></td></tr></table>";
                }
                else
                {
                    this.labShowUserInfo.Text = this.labShowUserInfo.Text + "<table borderColor='#cccccc' cellSpacing='0' borderColorDark='#cccccc' cellPadding='0' border='0' align='center' width='650'><tr  height='70'><td></td></tr></table>";
                }
            }
            adapter.Dispose();
            selectConnection.Close();
            selectConnection.Dispose();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            this.int_0 = Convert.ToInt32(base.Request["ID"].ToString());
            this.string_0 = base.Server.UrlDecode(base.Request["UserList"].ToString());
            if ((this.httpCookie_0 != null) && !(this.httpCookie_0.Value == ""))
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString + "--打印准考证信息";
                if (!base.IsPostBack)
                {
                    this.method_0();
                }
            }
            else
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
        }
    }
}

